function getSingle(fn) {
  let result;

  return function () {
    return result || (result = fn.apply(this, arguments));
  };
}

function createLoginLayout() {
  const ODiv = document.createElement("div");
  ODiv.innerHTML = "login";
  ODiv.style.color = "red";
  ODiv.style.display = "none";
  document.appendChild(ODiv);
  return ODiv;
}

const createLoginLayoutFun = getSingle(createLoginLayout);

document.getElementById("login").onclick = function () {
  var loginLayout = createLoginLayoutFun();
  loginLayout.style.display = "block";
};
